
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>增修类型</title>
    <link type="text/css" href="../../../res/layui/css/layui.css" rel="stylesheet" />
    <script type="text/javascript" src="../../../res/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="../../../res/layui/layui.js"></script>
    <script type="text/javascript" src="../../../res/js/jqueryform.js"></script>
    <script src="../../../res/tools.js"></script>
    <script language="javascript">
        $(function(){
            function test(func){
                var start = new Date().getTime();
                func();
                var end = new Date().getTime();
                return (end - start)+"ms";
            }
            $('.form').inform();
        });
    </script>
</head>
<body>
<style>
    .layui-input, .layui-textarea {
        width: 400px;
        margin-top: 35px;
        display: block;
        padding-left: 10px;
    }
    .layui-form-selected dl {
        margin-left: 110px;
        display: block;
    }
    .layui-form-item .layui-input-inline {
        float: left;
        margin-left: 110px;
        width: 190px;
        margin-top: -65px;
    }
    #xz{
        margin-top: 50px;
        margin-left: 26px;
    }
</style>
<div class="form">
    <form action="" method="post" name="myform" id="myform" enctype="multipart/form-data">
        <input type="hidden" name="typeId"  id="typeId"  class="width" placeholder="药材ID" />


        <div class="layui-form-item">
            <label class="layui-form-label">药材名称：</label>
            <div class="layui-input-block layui-width21em">
                <input type="text" id="typeName" name="typeName" placeholder="填写药材名称" maxlength="20" lay-verify="required" class="layui-input" autocomplete="off">
            </div>
        </div>

        <div id="xz">材料类型</div>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <select  name="typeId2"  id="typeId2" autocomplete="off"  class="layui-input">
                    <option value="23d829ea-20d1-4aba-bd77-4a556f613735" placeholder="果实类"></option>
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux"></div>
        </div>
        <div class="item">
            <span></span>
            <div id="div" style="margin-left: 240px">
                <label><button type="button" id="btn" class="layui-btn" >提交</button></label>
                <label><button type="submit" class="layui-btn" >重置</button></label>
            </div>
        </div>
    </form>
</div>

<script>
    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form
        var table = layui.table
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        $(function () {
            $("#btn").click(function () {
                var url ="/hqRawmaterialType/insert";
                var formDate = new FormData(document.getElementById("myform"));
                console.info(formDate)
                $.ajax({
                    url:url,
                    data:formDate,
                    processData:false,
                    contentType:false,
                    dataType:'json',
                    type:'POST',
                    success:function (obj) {
                        layer.msg(obj.message)
                        if(obj.status == 1){
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.treeGrid.reload('testReload');
                            parent.layer.close(index);
                            parent.layer.msg(obj.message);　
                        }
                    },
                })
            })
            url = "/hqRawmaterialType/selectTypeName";
            data = null;
            $.get(url,data,function (obj) {
                $("#typeId2").val("");
                $.each(obj,function(index,item){
                    $("#typeId2").append("<option value="+item.typeId+"> "+item.typeName+"</option>");
                })
                //重新渲染
                form.render('select');
            },"json");
        })
    });
</script>
</body>
</html>